package com.molan.molan_music.service.impl;

import com.molan.molan_music.dao.RoleDao;
import com.molan.molan_music.entity.Role;
import com.molan.molan_music.mapper.RoleMapper;
import com.molan.molan_music.service.RoleService;
import com.molan.molan_music.vo.RoleVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class RoleServiceImpl implements RoleService {

    @Resource
    private RoleDao roleDao;
    @Override
    public List<RoleVo> getRoles() {
        List<Role> roleList = roleDao.listAll();
        List<RoleVo> roleVoList = new ArrayList<>();
        for (Role role : roleList) {
            RoleVo roleVo = new RoleVo();
            BeanUtils.copyProperties(role,roleVo);
            roleVoList.add(roleVo);
        }

        return roleVoList;
    }
}
